﻿using SolidEdgeConstants;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;
using System.Windows;
using System.Windows.Forms;
using TGCommunity.AddIn;

namespace TGComacAddin
{
    internal class TGSelectVertexCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectVertexCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateVertex;
            _commandId = 100;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (null == pGraphicDispatch)
                return;
            SolidEdgePart.PartDocument pPartDoc= _application.ActiveDocument as SolidEdgePart.PartDocument;
            if (pPartDoc == null)
                return;
            ulong entId =  pPartDoc.GetEntityID(pGraphicDispatch);
            _application.StatusBar = string.Format("拓扑对象ID:" + entId);
        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode= (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }


    internal class TGSelectEdgeCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectEdgeCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateEdge;
            _commandId = 101;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            try
            {
                if (null == pGraphicDispatch)
                    return;
                SolidEdgePart.PartDocument pPartDoc = _application.ActiveDocument as SolidEdgePart.PartDocument;
                if (pPartDoc == null)
                    return;
                ulong entId = pPartDoc.GetEntityID(pGraphicDispatch);
                _application.StatusBar = string.Format("拓扑对象ID:" + entId);
                SolidEdgeGeometry.Edges edges = pGraphicDispatch as SolidEdgeGeometry.Edges;
                if (null != edges)
                {
                    var cnt = edges.Count;
                    int aaa = 0;
                }
            }
            catch(Exception e)
            {

            }

        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
            _mouse.GroupLocateMode = 1;
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }


    internal class TGSelectFaceCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectFaceCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateFace;
            _commandId = 102;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (null == pGraphicDispatch)
                return;
            SolidEdgePart.PartDocument pPartDoc = _application.ActiveDocument as SolidEdgePart.PartDocument;
            if (pPartDoc == null)
                return;

            ulong entId = pPartDoc.GetEntityID(pGraphicDispatch);
            _application.StatusBar = string.Format("拓扑对象ID:" + entId);
        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
            _mouse.GroupLocateMode = 2;
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }


    internal class TGSelectBodyCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectBodyCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateBody;
            _commandId = 103;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (null == pGraphicDispatch)
                return;
            SolidEdgePart.PartDocument pPartDoc = _application.ActiveDocument as SolidEdgePart.PartDocument;
            if (pPartDoc == null)
                return;
            ulong entId = pPartDoc.GetEntityID(pGraphicDispatch);
            _application.StatusBar = string.Format("拓扑对象ID:" + entId);
        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }


    internal class TGSelectFeatureCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectFeatureCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateFeature;
            _commandId = 104;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (null == pGraphicDispatch)
                return;
            SolidEdgePart.PartDocument pPartDoc = _application.ActiveDocument as SolidEdgePart.PartDocument;
            if (pPartDoc == null)
                return;

            try
            {
                ulong entId = pPartDoc.GetObjectID(pGraphicDispatch);
                _application.StatusBar = string.Format("特征ID:" + entId);
                SolidEdgePart.Sketch3D sketch = pGraphicDispatch as SolidEdgePart.Sketch3D;
                int aaa = 0;
            }
            catch (Exception e)
            {

            }

        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }


    internal class TGSelectSingleEdgeCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectSingleEdgeCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateEdge;
            _commandId = 106;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            try
            {
                if (null == pGraphicDispatch)
                    return;
                SolidEdgePart.PartDocument pPartDoc = _application.ActiveDocument as SolidEdgePart.PartDocument;
                if (pPartDoc == null)
                    return;
                ulong entId = pPartDoc.GetEntityID(pGraphicDispatch);
                _application.StatusBar = string.Format("拓扑对象ID:" + entId);
                SolidEdgeGeometry.Edges edges = pGraphicDispatch as SolidEdgeGeometry.Edges;
                if (null != edges)
                {
                    var cnt = edges.Count;
                    int aaa = 0;
                }
            }
            catch (Exception e)
            {

            }

        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }

    internal class TGSelectSingleFaceCmd : TGCmdPopup
    {
        private SolidEdgeConstants.seLocateFilterConstants _locateFilter;

        public TGSelectSingleFaceCmd()
        {
            _locateFilter = seLocateFilterConstants.seLocateFace;
            _commandId = 107;
        }

        /// <summary>
        /// 命令对象初始化
        /// </summary>
        public override void Initialize()
        {
            _application = TGC_Constants.SEAPP;
        }

        public override void MouseClick(short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (null == pGraphicDispatch)
                return;
            SolidEdgePart.PartDocument pPartDoc = _application.ActiveDocument as SolidEdgePart.PartDocument;
            if (pPartDoc == null)
                return;

            ulong entId = pPartDoc.GetEntityID(pGraphicDispatch);
            _application.StatusBar = string.Format("拓扑对象ID:" + entId);
        }

        public override void Activate()
        {
            _mouse.ScaleMode = 1;
            _mouse.WindowTypes = 1;

            _mouse.LocateMode = (int)SolidEdgeConstants.seLocateModes.seLocateSimple;
            _mouse.ClearLocateFilter();
            _mouse.AddToLocateFilter((int)_locateFilter);
        }

        //public override void RunCommandWithPopup()
        //{

        //}

        public override long WindowProc(object pTheDoc, object pTheView, uint nMsg, ulong wParam, long lParam)
        {
            return 0;
        }

    }


}
